# Contributor: Rasmus Thomsen <oss@cogitri.dev>
# Maintainer: Natanael Copa <ncopa@alpinelinux.org>
pkgname=tinysparql
pkgver=3.8.0
pkgrel=1
pkgdesc="Personal search tool and storage system"
url="https://tracker.gnome.org/"
arch="all"
license="GPL-2.0-or-later"
makedepends="
	asciidoc
	bash-completion-dev
	dbus-dev
	docbook-xsl-nons
	glib-dev
	gobject-introspection-dev
	icu-dev
	json-glib-dev
	libsoup3-dev
	libstemmer-dev
	libxml2-dev
	meson
	py3-gobject3
	py3-setuptools
	sqlite-dev
	networkmanager-dev
	vala
	gi-docgen
	"
checkdepends="
	bash
	dbus
	mandoc
	"
subpackages="
	$pkgname-dbg
	$pkgname-dev
	$pkgname-doc
	$pkgname-lang
	lib$pkgname:libs
	$pkgname-bash-completion
	"
source="https://download.gnome.org/sources/tinysparql/${pkgver%.*}/tinysparql-$pkgver.tar.xz
	fix-tests.patch
	"

# for backwards compatibility
replaces="tracker"
provides="tracker=$pkgver-r$pkgrel"

build() {
	abuild-meson \
		-Db_lto=true \
		-Ddocs=true \
		-Dman=true \
		-Dsystemd_user_services=false \
		-Dintrospection=enabled \
		-Dtests="$(want_check && echo true || echo false)" \
		. output
	meson compile -C output
}

check() {
	XDG_RUNTIME_DIR="$(mktemp -p "$builddir" -d)" \
	MANPATH="$builddir"/output/docs \
	dbus-run-session -- \
	meson test -t 10 --no-rebuild --print-errorlogs -C output
}

package() {
	DESTDIR="$pkgdir" meson install --no-rebuild -C output
}

libs() {
	default_libs
	replaces="libtracker"
	provides="libtracker=$pkgver-r$pkgrel"
	amove usr/lib/girepository-1.0
}

sha512sums="
e5c17bb7cfccc5921a4acf489385660014f7277dce4aa1cf98d264a3e6629aa66f93d63f5e08f7f921f5e59bd349d05ec27f9e27c5a3ad75598396a3421cc951  tinysparql-3.8.0.tar.xz
338dd00feecddd2b066f2a1cc80c6b5cced65939112a5f2ef801549556238b89c88ed2fe69db6e1c04170831012698f0f0d921d7620d752dd8b25fdf50742dad  fix-tests.patch
"
